package com.whatever;

import java.io.*;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.View;
import android.widget.*;

public class FileIOActivity extends Activity implements OnClickListener {
    
	private EditText textBox;
	private Button[] button;
	private int btnId;
	private int[] buttonMap = {
			R.id.button0,
			R.id.button1,
			R.id.button2,
			R.id.button3
	};
	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        textBox = (EditText)findViewById(R.id.editText0);
        textBox.setHint("Enter data here...");
        
		for(int i = 0; i < buttonMap.length; i++) {
			button[i] = (Button)findViewById(buttonMap[i]);
			button[i].setOnClickListener((android.view.View.OnClickListener) this);
		}
		
		
    }

	public void onClick(View v) {
		btnId = v.getId();
		for(int i = 0; i < buttonMap.length; i++) {
			if(btnId == buttonMap[i]) {
				btnId = i;
			}
		}
		
		if(btnId == 0) {
			try {
				File myFile = new File("/sdcard/File.txt");
				myFile.createNewFile();
				FileOutputStream fOut = new FileOutputStream(myFile);
			}catch(IOException ioe) {
				System.out.println(ioe);
			}
		}
	}

	public void onClick(DialogInterface dialog, int which) {
		// TODO Auto-generated method stub
		
	}
}